package com.atguigu.java.ai.langchain4j.config;

import com.atguigu.java.ai.langchain4j.store.MongoChatMemoryStore;
import dev.langchain4j.data.message.ChatMessageDeserializer;
import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: Mikey
 * @Date: 2025/8/30 12:40
 * @Description:
 **/
@Configuration
public class SeparateChatAssistantConfig {
    //注入持久化对象
    @Resource
    private MongoChatMemoryStore mongoChatMemoryStore;


    @Bean
    public ChatMemoryProvider chatMemoryProvider(){
        return memoryId ->
                MessageWindowChatMemory.builder()
                        .chatMemoryStore(mongoChatMemoryStore)
                        .id(memoryId)
                        .maxMessages(10)
                        .build();
    }
}
